using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Joy.Erp.BasicArchives.Core.Filters;

namespace Joy.Erp.BasicArchives.Procurements
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("PurchaseRequisition")]
    [Route("api/basic-archives/purchase-requisition")]
    public partial class PurchaseRequisitionController : BasicArchivesController, IPurchaseRequisitionAppService
    {
        protected IPurchaseRequisitionAppService PurchaseRequisitionAppService => LazyServiceProvider.LazyGetRequiredService<IPurchaseRequisitionAppService>();

        [HttpGet]
        [Route("{id}")]
        public Task<PurchaseRequisitionDto> GetAsync(Guid id)
        {
            return PurchaseRequisitionAppService.GetAsync(id);
        }

        [HttpGet]
        [Route("child/{id}")]
        public Task<PurchaseRequisitionLineDto> GetChildAsync(Guid id)
        {
            return PurchaseRequisitionAppService.GetChildAsync(id);
        }

        [HttpGet]
        [Route("find")]
        public Task<PurchaseRequisitionDto> FindAsync(string filter)
        {
            return PurchaseRequisitionAppService.FindAsync(filter);
        }

        [HttpGet]
        [Route("find-by-source-key")]
        public Task<PurchaseRequisitionDto> FindBySourceKeyAsync(string sourceKey, string sourceType)
        {
            return PurchaseRequisitionAppService.FindBySourceKeyAsync(sourceKey, sourceType);
        }

        [HttpGet]
        public Task<PagedResultDto<PurchaseRequisitionDto>> GetListAsync(FilterRequestDto input)
        {
            return PurchaseRequisitionAppService.GetListAsync(input);
        }

        [HttpPost]
        [Route("query")]
        public Task<PagedResultDto<PurchaseRequisitionDto>> QueryAsync(FilterGroupRequestDto input)
        {
            return PurchaseRequisitionAppService.QueryAsync(input);
        }

        [HttpPost]
        [Route("query-children")]
        public Task<PagedResultDto<PurchaseRequisitionLineDto>> QueryChildrenAsync(FilterGroupRequestDto input)
        {
            return PurchaseRequisitionAppService.QueryChildrenAsync(input);
        }

        [HttpPost]
        public Task<PurchaseRequisitionDto> CreateAsync(PurchaseRequisitionCreateDto input)
        {
            return PurchaseRequisitionAppService.CreateAsync(input);
        }

        [HttpPut]
        [Route("{id}")]
        public Task<PurchaseRequisitionDto> UpdateAsync(Guid id, PurchaseRequisitionUpdateDto input)
        {
            return PurchaseRequisitionAppService.UpdateAsync(id, input);
        }

        [HttpPost]
        [Route("submit")]
        public Task<PurchaseRequisitionDto> SubmitAsync(Guid id)
        {
            return PurchaseRequisitionAppService.SubmitAsync(id);
        }

        [HttpPost]
        [Route("approve")]
        public Task<PurchaseRequisitionDto> ApproveAsync(Guid id)
        {
            return PurchaseRequisitionAppService.ApproveAsync(id);
        }

        [HttpPost]
        [Route("unapprove")]
        public Task<PurchaseRequisitionDto> UnApproveAsync(Guid id)
        {
            return PurchaseRequisitionAppService.UnApproveAsync(id);
        }

        [HttpDelete]
        [Route("{id}")]
        public Task DeleteAsync(Guid id)
        {
            return PurchaseRequisitionAppService.DeleteAsync(id);
        }

        [HttpPost]
        [Route("batch-create")]
        public Task<List<PurchaseRequisitionDto>> BatchCreateAsync(List<PurchaseRequisitionCreateDto> inputs, bool useBulk = false)
        {
            return PurchaseRequisitionAppService.BatchCreateAsync(inputs, useBulk);
        }

        [HttpPut]
        [Route("batch-update")]
        public Task<List<PurchaseRequisitionDto>> BatchUpdateAsync(List<PurchaseRequisitionBatchUpdateDto> inputs, bool useBulk = false)
        {
            return PurchaseRequisitionAppService.BatchUpdateAsync(inputs, useBulk);
        }

        [HttpPost]
        [Route("batch-delete")]
        public Task BatchDeleteAsync(List<Guid> ids, bool useBulk = false)
        {
            return PurchaseRequisitionAppService.BatchDeleteAsync(ids, useBulk);
        }
    }
} 